<template>
  <div class="goods-box4">
    <div class="search" style="text-align: center">
      <el-input
        v-model="searchValue"
        maxlength="100"
        clearable
        style="width: 290px"
      />
      <img
        src="../assets/img/search.png"
        @click="handleSearch"
        class="search-icon"
      />
    </div>
    <div
      class="goods"
      v-for="(item, index) in cgoods"
      :style="
        index === cgoods.length - 1 ? '' : 'border-bottom:1px solid #f2f2f2;'
      "
      :key="index"
    >
      <img src="../assets/file/avatar/experta.png" alt="" />
      <div class="info">
        <p class="content">
          <span style="margin-right: 50px">专家姓名：{{ item.realName }}</span>
          <span>职称：{{ item.position }}</span>
        </p>
        <p class="content">
          <span>从事专业：{{ item.profession }}</span>
          <span>联系电话：{{ item.phone }}</span>
        </p>
        <p class="content">
          <span>单位：{{ item.belong }}</span>
        </p>
      </div>
      <div class="info2">
        <span
          class="question-btn"
          @click="handleQuestion(item)"
          style="margin-right: 20px"
          >向我提问</span
        >
        <span class="question-btn" @click="handleAppoint(item)">线下预约</span>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";

const router = useRouter();
const searchValue = ref("");
const props = defineProps({
  cgoods: Array,
});

const handleQuestion = (item) => {
  router.push(`/home/question?id=${item.userName}`).catch((err) => err);
};

const handleAppoint = (item) => {
  router.push(`/home/appointment?id=${item.userName}`).catch((err) => err);
};

const handleSearch = () => {
  emit("handleSearch", searchValue.value);
};

</script>

<style lang="less" scoped>
.search {
  height: 60px;
  background-color: white;
  padding: 10px 20px;
  background-color: white;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  .search-icon,
  .el-input {
    cursor: pointer;
    height: 40px;
  }
}

.goods-box4 {
  background-color: #fff;
  width: 1300px;
  margin: 0 auto;

  .goods {
    width: 1300px;
    height: 110px;
    padding: 10px 20px;
    background-color: white;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    img {
      width: 100px;
      height: 100px;
      margin-right: 20px;
      border-radius: 6px;
    }

    .info {
      width: 800px;
      margin-top: 10px;
      font-size: 14px;
      .initiator {
        color: #666;
      }

      .title {
        /*超出的部分隐藏*/
        overflow: hidden;
        /*文字用省略号替代超出的部分*/
        text-overflow: ellipsis;
        /*弹性伸缩盒子模型显示*/
        display: -webkit-box;
        /*限制在一个块元素显示文本的行数*/
        -webkit-line-clamp: 1;
        /*设置或检索伸缩盒对象的子元素排列方式*/
        -webkit-box-orient: vertical;
      }

      .content {
        height: 20px;
        /*超出的部分隐藏*/
        overflow: hidden;
        /*文字用省略号替代超出的部分*/
        text-overflow: ellipsis;
        /*弹性伸缩盒子模型显示*/
        display: -webkit-box;
        /*限制在一个块元素显示文本的行数*/
        -webkit-line-clamp: 7;
        /*设置或检索伸缩盒对象的子元素排列方式*/
        -webkit-box-orient: vertical;
      }

      .price {
        font-weight: bold;
        display: block;
        color: red;
      }
    }
  }
}
.info2 {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: flex-end;
  .question-btn {
    cursor: pointer;
    color: #67c23a;
    &:hover {
      text-decoration: underline;
      color: #035d1c;
    }
  }
}
.search /deep/ .el-input--suffix .el-input__inner {
  height: 35px;
  line-height: 35px;
}
</style>